// The GuiControl base class
// all renderable gui controls inherit from this
#pragma once

#include <string>
#include <base/d3d.h>
#include <scene/SceneNode.h>

class GuiControl : public SceneNode {
public:
   GuiControl()  {_enabled = true;}
   virtual ~GuiControl() {};

   // different draw managed by controller (called every frame if visible)
   virtual void Draw(Device * device, double tElapsed) const = 0;

   // updates the control's information
   virtual void Update(long mouseX, long mouseY, unsigned long key, double tElapsed) {}

   // tested for mouse collion
   virtual bool Collide(long mouseX, long mouseY) {
      return ((mouseY >= _y) && (mouseX >= _x) && 
              (mouseY <= _y + _height) && (mouseX <= _x + _width));
   }

   // helpers for turning the control on/off
   inline void On() {_enabled = true; _visible = true;}
   inline void Off() {_enabled = false; _visible = false;}

   // coordinate junk
   inline void SetCoords(float x, float y) {_x = x; _y = y;}
   inline void SetX(float x) {_x = x;}
   inline void SetY(float y) {_y = y;}

   inline void SetWidth(float wide) {_width = wide;}
   inline void SetHeight(float high) {_height = high;}

   // control is enabled (recieving/sending input)
   inline bool IsEnabled() {return _enabled;}
   inline void SetEnabled(bool val) {_enabled = val;}

   // is visible (drawn)
   inline bool IsVisible() {return _visible;}
   inline void SetVisible(bool val) {_visible = val;}

protected:
   float _z;              // Z level
   float _x;
   float _y;
   float _width;
   float _height;

private:
   bool _visible;
   bool _enabled;
};

// Draws text with a small shadow
void DrawShadowedText(Device * device, std::string text, long font, long x, long y, long width, long height, unsigned long color);
